const path = require('path')
let packageName = require('./package.json').name
const resolve = (dir) => {
  return path.join(__dirname, dir)
}

module.exports = {
  // publicPath: './',
  lintOnSave: process.env.NODE_ENV !== 'production',
  productionSourceMap: true,
  configureWebpack: {
    output: {
      library: `${packageName}-[name]`,
      libraryTarget: 'umd',
      jsonpFunction: `webpackJsonp_${packageName}`,
    },
    externals: {},
  },
  chainWebpack: (config) => {
    config.resolve.alias.set('@', resolve('src'))
  },
  devServer: {
    // 关闭主机检查，使微应用可以被 fetch
    disableHostCheck: true,
    // 配置跨域请求头，解决开发环境的跨域问题
    headers: {
      'Access-Control-Allow-Origin': '*',
    },
  },
}
